#!/bin/sh
#
# see: dh_installdeb(1)

set -e

package="ti-pru-cgt-installer"

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

remove_file () {
	if [ -f ${wfile} ] ; then
		rm -f ${wfile}
	fi
}

remove_dir () {
	if [ -d ${wdir} ] ; then
		rm -rf ${wdir}
	fi
}

remove_all() {
	wfile="/usr/bin/abspru" ; remove_file
	wfile="/usr/bin/acpiapru" ; remove_file
	wfile="/usr/bin/arpru" ; remove_file
	wfile="/usr/bin/asmpru" ; remove_file
	wfile="/usr/bin/cgpru" ; remove_file
	wfile="/usr/bin/clistpru" ; remove_file
	wfile="/usr/bin/clpru" ; remove_file
	wfile="/usr/bin/dempru" ; remove_file
	wfile="/usr/bin/dispru" ; remove_file
	wfile="/usr/bin/embedpru" ; remove_file
	wfile="/usr/bin/hexpru" ; remove_file
	wfile="/usr/bin/ilkpru" ; remove_file
	wfile="/usr/bin/libinfopru" ; remove_file
	wfile="/usr/bin/lnkpru" ; remove_file
	wfile="/usr/bin/nmpru" ; remove_file
	wfile="/usr/bin/ofdpru" ; remove_file
	wfile="/usr/bin/optpru" ; remove_file
	wfile="/usr/bin/strippru" ; remove_file
	wfile="/usr/bin/xrefpru" ; remove_file

	#2.1.1 added: /usr/share/doc/ti/cgt-pru/DefectHistory.txt
	wdir="/usr/share/doc/ti/cgt-pru/" ; remove_dir

	wfile="/usr/share/man/man1/abspru.1" ; remove_file
	wfile="/usr/share/man/man1/acpiapru.1" ; remove_file
	wfile="/usr/share/man/man1/asmpru.1" ; remove_file
	wfile="/usr/share/man/man1/cgpru.1" ; remove_file
	wfile="/usr/share/man/man1/clpru.1" ; remove_file
	wfile="/usr/share/man/man1/dempru.1" ; remove_file
	wfile="/usr/share/man/man1/dispru.1" ; remove_file
	wfile="/usr/share/man/man1/embedpru.1" ; remove_file
	wfile="/usr/share/man/man1/hexpru.1" ; remove_file
	wfile="/usr/share/man/man1/ilkpru.1" ; remove_file
	wfile="/usr/share/man/man1/libinfopru.1" ; remove_file
	wfile="/usr/share/man/man1/lnkpru.1" ; remove_file
	wfile="/usr/share/man/man1/nmpru.1" ; remove_file
	wfile="/usr/share/man/man1/ofdpru.1" ; remove_file
	wfile="/usr/share/man/man1/optpru.1" ; remove_file
	wfile="/usr/share/man/man1/strippru.1" ; remove_file
	wfile="/usr/share/man/man1/xrefpru.1" ; remove_file

	wdir="/usr/share/ti/cgt-pru/" ; remove_dir

	wfile="/var/cache/${package}/ti_cgt_pru_2.1.0_armlinuxa8hf_busybox_installer.sh" ; remove_file
	wfile="/var/cache/${package}/ti_cgt_pru_2.1.1_armlinuxa8hf_busybox_installer.sh" ; remove_file
	wfile="/var/cache/${package}/ti_cgt_pru_2.1.2_armlinuxa8hf_busybox_installer.sh" ; remove_file
	wfile="/var/cache/${package}/ti_cgt_pru_2.1.3_armlinuxa8hf_busybox_installer.sh" ; remove_file
	wfile="/var/cache/${package}/ti_cgt_pru_2.1.4_armlinuxa8hf_busybox_installer.sh" ; remove_file
	#wfile="/var/cache/${package}/ti_cgt_pru_2.1.5_armlinuxa8hf_busybox_installer.sh" ; remove_file
}

case "$1" in
    remove|upgrade|deconfigure)
	remove_all
    ;;

    failed-upgrade)
    ;;

    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0


